/**
  ******************************************************************************
  * @file           : XYXKC_ASR.h
  * @author         : admin
  * @brief          : None
  * @attention      : None
  * @date           : 2025/2/27
  ******************************************************************************
  */

#ifndef XYXKC_ASR_H
#define XYXKC_ASR_H
#include <Arduino.h>
#include <ArduinoJson.h>
#include <WebSocketsClient.h>
#include <driver/i2s.h>
#include "freertos/FreeRTOS.h"
#include "driver/gpio.h"

#define I2S_DMA_BUF_LEN  256
#define ADC_INPUT ADC1_CHANNEL_0
class XYXKC_ASR {
    public:
        XYXKC_ASR();

        void asrInit(String token,String appKey);
        String getAsrResult();
        void  enableSpeechRecognition();
        void stopSpeechRecognition();
        static void webSocketEvent(WStype_t type, uint8_t * payload, size_t length);
        static void recordSound(void *pvParameters);
        bool isIdentificationSuccessful();
    private:

        void _i2sInit();
        String _token;
        String _jsonString;
        bool _enableIt = false;
        String _result = "";
        bool _isIdentify = false;

        WebSocketsClient _webSocket;

};


#endif
